/*
 * (C) Copyright 2016 Ymatou (http://www.ymatou.com/).
 * 
 * All rights reserved.
 */
package com.ymatou.iapi.userservice.parameter.enums;


/**
 * 渠道来源
 * @author zhongwei
 *
 */
public enum ChannelSourceEnum {

    /**
     * 洋码头
     */
    Other(0, "Other"),

    /**
     * 阿里
     */
    Alipay(3, "Alipay"),

    /**
     * QQ
     */
    QQ(4, "QQ"),

    /**
     * 新浪微博
     */
    Weibo(5, "Weibo"),

    /**
     * 微信
     */
    WeiXin(6, "WeiXin"),
    ;

    private Integer code;

    private String message;

    ChannelSourceEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 通过错误码获取枚举项
     *
     * @param code
     * @return
     */
    public static ChannelSourceEnum getByCode(Integer code) {
        for (ChannelSourceEnum channelSourceEnum : ChannelSourceEnum.values()) {
            if (channelSourceEnum.getCode() == code) {
                return channelSourceEnum;
            }
        }
        return null;
    }
}
